<template>
  <div class="lazy">
    <h2>lazy</h2>
  </div>
</template>

<script setup lang="ts">
  const BASE_URL = "http://codercba.com:9060/juanpi/api";
  interface IResultData {
    code: number;
    data: any;
  }
  // 1. useFetch 默认会阻塞 页面的导航
  const { data } = await useFetch<IResultData>(`${BASE_URL}/homeInfo`, {
    method: "GET",
    lazy: true, // 默认是 true
  });
  console.log(data.value?.data);

  watch(data, (newVal) => {
    console.log(newVal);
  });

  onMounted(() => {
    console.log("mounted");
  });
</script>

<style lang="less" scoped>
  .lazy {
  }
</style>
